package com.libweb.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.libweb.model.dao.BoardDao;
import com.libweb.model.dao.MemberDao;
import com.libweb.model.dto.Board;
import com.libweb.model.dto.Member;

@WebServlet("/member/update.action")
public class MemberUpdateServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
		
		//1. Board 객체를 만들고 사용자가 입력한 데이터를 저장
		Member member = new Member();
		member.setMemberId(req.getParameter("memberid"));
		member.setName(req.getParameter("name"));
		member.setPhoneNo(req.getParameter("phoneno"));
		member.setAddress(req.getParameter("address"));

		//2. 데이터베이스에 변경된 내용 적용
		MemberDao dao = new MemberDao();
		dao.updateMember(member);
		
		//3. 홈 페이지로 이동
		resp.sendRedirect("/libweb/home.action");	
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
		
		req.setCharacterEncoding("utf-8");
		
		doGet(req, resp);
	}
	
}






